

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class Test1
 */
@WebServlet("/Test1")
public class Test1 extends HttpServlet {
	private static final long serialVersionUID = 1L;

    /**
     * Default constructor. 
     */
    public Test1() {
        // TODO Auto-generated constructor stub
    }
    
    
    
	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub

		String someText = request.getParameter("someText");
		ServletContext servletContext  = this.getServletContext();
		InputStream is = servletContext.getResourceAsStream("/WEB-INF/LogFile.properties");
		Properties props = new Properties();
	    props.load(is);
	 
	    String logDir = props.getProperty("log path", "C:\\Downloads");
		
	    String logFile = logDir + "\\someText.txt";
		
	    FileWriter fstream = new FileWriter(logFile);
		BufferedWriter out = new BufferedWriter(fstream);
		out.write(someText);
		  //Close the output stream
		out.close();
	
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
